﻿function valaxyCircle(config) {
    this.config = config;
    this._init();
}

valaxyCircle.prototype._init = function () {
    var me = this;
    var handle = setInterval(me.config.execute, me.config.timeout);
    me.handle = handle;
}


valaxyCircle.prototype.stop = function () {
    var me = this;
    clearInterval(me.handle);
}


// 循环直至结束
var c = new valaxyCircle({
    execute: function () {
        if (window.extStatusHandler) {
            window.extStatusHandlerBak = window.extStatusHandler;
            window.extStatusHandler = function (o) {
                window.extStatusHandlerBak(o);
                o = $.parseJSON(o);
                if (o.song) {
                    $('<div id="douban_title">' + o.song.title + '</div>').appendTo('body').hide();
                    $('<div id="douban_artist">' + o.song.artist + '</div>').appendTo('body').hide();
                    console.log('豆瓣切歌拉');
                }
            };
            c.stop();
        }
        else {
            alert('还不行');
        }
    },
    timeout: 500
});

